package LeetCode;

public class LeetCodeMain8 {
    public int dayOfYear(String date) {
        String[] str=date.split("-");
        int[] day=new int[]{0,31,28,31,30,31,30,31,31,30,31,30,31};
        int year=Integer.parseInt(str[0]);
        if (year%400==0||(year%4==0&&year/100!=0)){
            day[2]=29;
        }
        int mounth=Integer.parseInt(str[1]);
        int days=Integer.parseInt(str[2]);
        int sum=0;
        for (int i = 1; i <=mounth-1; i++) {
            sum+=day[i];
        }
        sum+=days;
        return sum;
    }
}
